import { createApp, ref, toRefs, isRef, h, reactive, readonly, computed, defineAsyncComponent } from 'vue'
import vant from 'vant';
import 'vant/lib/index.css'
import App from './App.vue'
import xue from "./lib/xue3"
import router from "./lib/router"
// 测试导入环境变量 在.env.development 中配置
console.log(`${import.meta.env.VITE_APP_API_URL}`)
const app = createApp(App)

//设置xue加载的基路径
xue.config.baseUrl = '/pages'
//给xue添加支持异步组件 defineAsyncComponent
const vloadc = (compPath, options) => {
    return defineAsyncComponent(xue.vload(compPath, options));
}
// 导出全局变量
Object.assign(app.config.globalProperties, {
   //比如导出 axios
})
// 暴露vue3的api
// 在html中使用 let {ref} =Vue
if (window) {
    window.Vue=window.Vue||{}
    Object.assign(window.Vue,{
        vload:xue.vload, //路由加载
        vloadc,          //局部组件加载
        ref, 
        toRefs, 
        isRef, 
        h, 
        reactive, 
        readonly, 
        computed 
    })
}
app.use(vant)
app.use(router)
app.mount('#app')
